package lab.gene.service.impl;

import java.util.Date;
import java.util.List;

import lab.gene.pojo.Gene;
import lab.gene.pojo.GenePlate6MP;
import lab.gene.dao.GeneDAO;
import lab.gene.dao.GenePlate6MPDAO;
import lab.gene.service.GenePlate6MPService;
import lab.user.dao.UserDAO;
import lab.user.pojo.User;

public class GenePlate6MPServiceImpl implements GenePlate6MPService {

	@Override
	public GenePlate6MP getGenePlate6MPByNameAndType(String geneName,
			String type) {
		// TODO Auto-generated method stub
		GenePlate6MPDAO dao = new GenePlate6MPDAO();
		GeneDAO gdao = new GeneDAO();
		Gene gene = gdao.getGene(geneName);;
		GenePlate6MP g = dao.getGenePlate6MPByNameAndType(gene, type);
		return g;
	}


	@Override
	public void addGenePlate6MP(String geneName, String type, Date recordDate, String strain, String intermediate, String comments, String userName) {
		// TODO Auto-generated method stub
		UserDAO udao = new UserDAO();
		GeneDAO gdao = new GeneDAO();
		Gene g = gdao.getGene(geneName);
		User u = udao.getUser(userName);
		GenePlate6MPDAO dao = new GenePlate6MPDAO();
		GenePlate6MP mp = new GenePlate6MP();
		mp.setComments(comments);
		mp.setDateModified(new Date());
		mp.setGene(g);
		mp.setIntermediate(intermediate);
		mp.setRecordDate(recordDate);
		mp.setStrain(strain);
		mp.setType(type);
		mp.setUser(u);
		dao.addGenePlate6MP(mp);

	}
	
	@Override
	public List<GenePlate6MP> getGenePlate6MPHistory(String geneName, String type) {
		List<GenePlate6MP> g = null;
		GeneDAO gdao = new GeneDAO();
		Gene gene = gdao.getGene(geneName);
		GenePlate6MPDAO dao = new GenePlate6MPDAO();
		g = dao.getGenePlate6MPHistory(gene, type);
		return g;
	}

}
